package com.greenleaf.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.greenleaf.entity.PdtClass;
import com.greenleaf.entity.SearchCon;
import com.greenleaf.service.PdtClassService;

@Controller
@RequestMapping("/pdtClass")
public class PdtClassController {
	@Resource
	private PdtClassService pdtClassService;
	
	@RequestMapping("/getAll")
	@ResponseBody
	//http://localhost:8080/Greenleaf/pdtClass/getAll
	public Object getAllPdtClass(SearchCon searchCon) {
		List<PdtClass> user = pdtClassService.getAllPdtClass(searchCon);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", "0");
		map.put("msg", "0");
		map.put("count",pdtClassService.getTotalPdtClass(searchCon));
		map.put("data", user);
		return map;
	}
	@RequestMapping("/add")
	@ResponseBody
	//http://localhost:8080/Greenleaf/pdtClass/add
	public Object addPdtClass(PdtClass pdtClass) {
		System.out.println(pdtClass);
		return pdtClassService.addPdtClass(pdtClass);
	}
	@RequestMapping("/update")
	@ResponseBody
	//http://localhost:8080/Greenleaf/pdtClass/update
	public Object updatePdtClass(PdtClass pdtClass) {
		//System.out.println(pdtClass);
		int r = pdtClassService.updatePdtClass(pdtClass);
		return r==1?true:false;
	}
	@RequestMapping("/del")
	@ResponseBody
	//http://localhost:8080/Greenleaf/pdtClass/del
	public Object delPdtClass(int pdtClassId) {
		//System.out.println(pdtId);
		return pdtClassService.delPdtClass(pdtClassId);
	}
}

